import {
  CoolController,
  BaseController,
  CoolCommException,
} from '@cool-midway/core';
import { Get, Inject, Query } from '@midwayjs/core';
import { MangoRequestService } from '../../../service/request';

/**
 * 获取影片相关接口
 */
@CoolController()
export class MangoAppOpenMovieController extends BaseController {
  @Inject()
  mangoRequestService: MangoRequestService;
  /**
   * 获取全国所有城市
   */
  @Get('/list', { summary: '获取全国所有城市' })
  async getList(@Query() query) {
    const url = '/api/621458c86a46f';
    try {
      return this.ok(await this.mangoRequestService.post(url, query));
    } catch (error) {
      throw new CoolCommException(error.message);
    }
  }
  /**
   * 搜索影片或影院
   */
  @Get('/search', { summary: '搜索影片或影院' })
  async search(@Query() query) {
    const url = '/api/6239842779163';
    try {
      return this.ok(await this.mangoRequestService.post(url, query));
    } catch (error) {
      throw new CoolCommException(error.message);
    }
  }
  /**
   * 影片信息&某城市下的影片排期
   */
  @Get('/detail', { summary: '影片信息&某城市下的影片排期' })
  async detail(@Query() query) {
    const url = '/api/6229af3c0ab74';
    try {
      return this.ok(await this.mangoRequestService.post(url, query));
    } catch (error) {
      throw new CoolCommException(error.message);
    }
  }
}
